package com.kx.kxpicture.common;

import com.kx.kxpicture.exception.ErrorCode;

/**
 * 返回结果工具类
 *
 * @author kuangxin
 * date 2025/8/13
 */
public class ResultUtils {
    /**
     * 成功
     * @author kuangxin
     * @date 2025/8/13
     */
    public static <T> BaseResponse<T> success(T data){
        return new BaseResponse<>(0,data,"ok");
    }

    /**
     * 失败
     * @author kuangxin
     * @date 2025/8/13
     */
    public static BaseResponse<?> error(ErrorCode errorCode){
        return new BaseResponse<>(errorCode);
    }

    /**
     * 失败
     * @author kuangxin
     * @date 2025/8/13
     */
    public static BaseResponse<?> error(int code,String message){
        return new BaseResponse<>(code,null,message);
    }

    public static BaseResponse<?> error(ErrorCode code,String message){
        return new BaseResponse<>(code.getCode(),null,message);
    }
}
